import React from 'react'
import { connect } from 'react-redux'
import {Tabs} from 'antd';
const TabPane = Tabs.TabPane;
import DingDing from 'containers/setting/development-platform/ding-ding';
import WeChat from 'containers/setting/development-platform/wechat';
import Lark from 'containers/setting/development-platform/lark';


class DevelopmentPlatformIndex extends React.Component{
  constructor(props){
    super(props);
    this.state = {};
  }

  componentWillMount(){
  }

  render () {
    const {currentPageRoute, isDingTalkEnv, authPolicyAll}= this.props;
    const {subFunctions}= currentPageRoute;
    return (
      <Tabs className='full-height-page full-page-margin'>
        {
          subFunctions.map(item => {
            const key = item.key;
            if (item.operationType !== 'H') {
              if (key === 'ding-ding') {
                return (
                  <TabPane tab={item.resourceName} key={key}>
                    <DingDing disabled={item.operationType === "R" || !authPolicyAll}/>
                  </TabPane>
                )
              } else if (key === 'wechat' && !isDingTalkEnv) {
                return (
                  <TabPane tab={item.resourceName} key={key}>
                    <WeChat disabled={item.operationType === "R" || !authPolicyAll}/>
                  </TabPane>
                )
              } else if (key === 'lark' && !isDingTalkEnv) {
                return (
                  <TabPane tab={item.resourceName} key={key}>
                    <Lark disabled={item.operationType === "R" || !authPolicyAll}/>
                  </TabPane>
                )
              } else {
                return null
              }
            } else {
              return null
            }
          })
        }
      </Tabs>
    )

  }


}
DevelopmentPlatformIndex.contextTypes = {
  router: React.PropTypes.object,
};
function mapStateToProps(state) {
  return {
    currentPageRoute: state.main.currentPageRoute,
    isDingTalkEnv: state.main.isDingTalkEnv,
    authPolicyAll: state.main.authPolicyAll,
  }
}

export default connect(mapStateToProps)(DevelopmentPlatformIndex);
